/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Principal;

import clases.SVGestorConexiones;

/**
 *
 * @author Juan
 */
public class frmMaquinas extends javax.swing.JInternalFrame {

    /**
     * Creates new form frmMaquinas
     */
    public frmMaquinas() {
        initComponents();
    }
    public static String a="";

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        rbtApagar = new javax.swing.JRadioButton();
        rbtReiniciar = new javax.swing.JRadioButton();
        rbtMensaje = new javax.swing.JRadioButton();
        txtMensaje = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        setTitle("Control de Maquinas");

        jPanel1.setBackground(new java.awt.Color(0, 102, 102));

        rbtApagar.setBackground(new java.awt.Color(204, 204, 204));
        rbtApagar.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        rbtApagar.setForeground(new java.awt.Color(255, 255, 255));
        rbtApagar.setText("Apagar");
        rbtApagar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtApagarActionPerformed(evt);
            }
        });

        rbtReiniciar.setBackground(new java.awt.Color(204, 204, 204));
        rbtReiniciar.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        rbtReiniciar.setForeground(new java.awt.Color(255, 255, 255));
        rbtReiniciar.setText("Reiniciar");
        rbtReiniciar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtReiniciarActionPerformed(evt);
            }
        });

        rbtMensaje.setBackground(new java.awt.Color(204, 204, 204));
        rbtMensaje.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        rbtMensaje.setForeground(new java.awt.Color(255, 255, 255));
        rbtMensaje.setText("Eniviar Mensaje");
        rbtMensaje.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtMensajeActionPerformed(evt);
            }
        });

        txtMensaje.setEnabled(false);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/1424575865_Refresh.png"))); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtMensaje)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(rbtApagar)
                        .addGap(18, 18, 18)
                        .addComponent(rbtReiniciar)
                        .addGap(18, 18, 18)
                        .addComponent(rbtMensaje)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rbtApagar)
                            .addComponent(rbtReiniciar)
                            .addComponent(rbtMensaje))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtMensaje, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(39, 39, 39))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void rbtApagarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtApagarActionPerformed
        // TODO add your handling code here:
        rbtReiniciar.setSelected(false);
        rbtMensaje.setSelected(false);
        a="A";
        txtMensaje.setEnabled(false);
    }//GEN-LAST:event_rbtApagarActionPerformed

    private void rbtReiniciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtReiniciarActionPerformed
        // TODO add your handling code here:
        rbtApagar.setSelected(false);
        rbtMensaje.setSelected(false);
        a="R";
        txtMensaje.setEnabled(false);
    }//GEN-LAST:event_rbtReiniciarActionPerformed

    private void rbtMensajeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtMensajeActionPerformed
        // TODO add your handling code here:
        rbtApagar.setSelected(false);
        rbtReiniciar.setSelected(false);
        txtMensaje.setEnabled(true);
        a="M";
    }//GEN-LAST:event_rbtMensajeActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        if("A".equals(a)){
            SVGestorConexiones.getInstancia().enviarMensaje(6, a);
        }
        if("R".equals(a)){
            SVGestorConexiones.getInstancia().enviarMensaje(6, a);
        }
        if("M".equals(a)){
            SVGestorConexiones.getInstancia().enviarMensaje(6, txtMensaje.getText());
            txtMensaje.setText("");
        }
    }//GEN-LAST:event_jButton1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton rbtApagar;
    private javax.swing.JRadioButton rbtMensaje;
    private javax.swing.JRadioButton rbtReiniciar;
    private javax.swing.JTextField txtMensaje;
    // End of variables declaration//GEN-END:variables
}
